home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
comm
/
tcp
/
SLIPShuttle.lha
/
SLIPShuttle
< prev
next >
Wrap
Text File
|
1995-04-15
|
6KB
|
184 lines
/* SLIPShuttle.rexx v2.3 By Karl Stenerud (esteneru@direct.ca) */
/************************** Basic Configuration *************************/
/* */
baud = 19200 /* baud rate */
phonenum = '000-0000' /* Server phone number */
username = 'your_username%c' /* Login name */
password = 'your_password' /* Login password */
/* */
/************************ Advanced Configuration ************************/
/* */
device = 'serial.device' /* device to use */
unit = 0 /* device unit */
devbuff = 4096 /* device buffer size */
xon = 0 /* 0=disable, 1=enable XON/XOFF */
init = 'ATZ' /* Modem init command */
dtr = 'AT&D0' /* DTR ignore command */
hispeed = 'AT&F2' /* Highspeed command */
esc = '+++' /* Modem escape sequence */
hangup = 'ATH0' /* Modem hangup command */
dialcmd = 'atdt' /* Modem dial command */
userprompt = 'Login: ' /* Host login prompt */
passprompt = 'Password: ' /* Host password prompt */
/* */
/************************* Expert Configuration *************************/
/* */
databits = 8 /* 7 or 8 */
parity = N /* None, Even, Odd, Mark, Space */
stopbits = 1 /* 1 or 2 */
breaktime = 250000 /* breaktime in microseconds */
slipprompt = 'SL/IP' /* SLIP init trigger */
slipstring1 = 'session from (' /* string up to first IP */
slipstring2 = ') to ' /* string to second IP */
gwfirst = 1 /* 1=gateway comes first */
S2OPT1 = '7WIRE' /* leave empty to disable */
S2OPT2 = 'EOFMODE' /* Disable if using A2232 */
MTU = 1006 /* Maximum Transfer Unit (sana2)*/
/************************************************************************/
/******************* Don't touch anything else below! *******************/
if ~show('L',"rexxsupport.library") then
if ~addlib('rexxsupport.library', 0, -30, 0) then exit 10
if ~show('L', "rexxserdev.library") then
if ~addlib( 'rexxserdev.library', 0, -30, 0) then exit 10
signal on break_c
CR = '0d'x
bigtest=0
if (show('p',AMITCP) == 1) then do
say 'AmiTCP is active! shutdown? [y/N]'
pull temp
if (temp == 'Y') then do
say 'Shutting down AmiTCP...'
address command 'execute AmiTCP:bin/stopnet'
delay(100)
say 'Hanging up modem...'
dev = SerOpen(device, unit)
SerWrite(dev, esc, length(esc))
Delay(100)
SerWrite(dev, hangup||CR, length(hangup||CR))
Delay(100)
SerWrite(dev, init||CR, length(init||CR))
SerClose(dev)
exit 0
end
else do;say 'Aborted (TCP was not shut down)';exit 5;end
end
dev = SerOpen(device, unit)
bigtest=1
temp = serquery(dev)
parse var temp . . temp1 .
if ((temp1 ~= 36) & (temp1 ~= 4)) then do
say 'Error accessing modem! ('||temp1')'
SerClose(dev)
exit 10
end
buffer = AllocMem(devbuff)
bigtest=2
addr = c2d(buffer)
SerSetParms(dev, baud, databits, parity, stopbits, xon, breaktime, devbuff)
SerWrite(dev, 'AT'||CR, 3)
delay(30)
status = SerQuery(dev)
parse var status junk1 bytes_read junk2 .
rstring = SerRead(dev, addr, bytes_read)
if pos('OK',rstring) == 0 then do
say 'You appear to still be connected with the remote server.'
say 'Attempt to resume AmiTCP? [y/N]'
pull temp
if (temp == 'Y') then do
SerClose(dev)
delay(30)
address command 'execute env:.last_ip'
exit 0
end
else do;say 'Aborting...';SerClose(dev);exit 5;end
end
SerClear(dev)
say 'Initializing modem...'
SerWrite(dev, init||CR, length(init||CR))
Delay(100)
SerWrite(dev, dtr||CR, length(dtr||CR))
Delay(10)
if baud > 19200 then do;SerWrite(dev, hispeed||CR, length(hispeed||CR));Delay(10);end
say 'Dialing ' phonenum '...'
OH = 0
do forever
delay(100)
if (OH == 0) then OH = SerWrite(dev, dialcmd||phonenum||CR, length(dialcmd||phonenum||CR))
status = SerQuery(dev)
parse var status junk1 bytes_read junk2 .
rstring = SerRead(dev, addr, bytes_read)
if (pos('CONNECT' , rstring) ~= 0) then leave
if (pos('BUSY' , rstring) ~= 0) then do;OH=0; say 'BUSY'; end
if (pos('VOICE' , rstring) ~= 0) then do;OH=0; say 'VOICE'; end
if (pos('NO CARRIER', rstring) ~= 0) then do;OH=0; say 'NO CARRIER'; end
if (pos('ERROR' , rstring) ~= 0) then do;OH=0; say 'ERROR'; end
end
call serwait(userprompt)
SerWrite(dev, username||CR, length(username||CR))
/* say userprompt||username */
call serwait(passprompt)
SerWrite(dev, password||CR, length(password||CR))
/* say passprompt */
call serwait(slipprompt)
if (gwfirst == 1) then parse var rstring . (slipstring1) gw (slipstring2) ip .
else parse var rstring . (slipstring1) ip (slipstring2) gw .
say 'Their Gateway address: '||gw
say 'Your IP address: '||ip
open(file,'env:.last_ip','W')
writeln(file,'execute amitcp:bin/startnet IP '||ip||' GW '||gw||' S2OPT "'||device||' '||unit||' '||baud||' 0.0.0.0 MTU='||MTU||' '||S2OPT1||' '||S2OPT2||'"')
close(file)
address command 'copy env:.last_ip envarc:'
SerClose(dev)
delay(50)
address command 'execute env:.last_ip'
FreeMem(buffer,devbuff)
exit 0
serwait:
string = arg(1)
test = 0
do until (test ~= 0)
status = SerQuery(dev)
parse var status junk1 bytes_read junk2 .
rstring = SerRead(dev, addr, bytes_read)
if (rstring ~= '') then say rstring
test = pos(string,rstring)
Delay(50)
end
return 0
break_c:
say '^C Break.'
if bigtest > 0 then do
say 'Hanging up modem...'
SerWrite(dev, esc, length(esc))
Delay(100)
SerWrite(dev, hangup||CR, length(hangup||CR))
Delay(100)
SerWrite(dev, init||CR, length(init||CR))
SerClose(dev)
end
if bigtest > 1 then do
say 'freeing buffer...'
FreeMem(buffer,devbuff)
end
exit 5